const express = require('express')
const bodyParser = require('body-parser');
const fs = require('fs')
const app = express()
const router = express.Router();
app.use(router)//引入路由
router.use(bodyParser.urlencoded({ extended: false }))
app.use(express.static('./static'))
router.get('/msg', (req, res) => {
    let ab = req.query.ab
    let id = req.query.id
   fs.readFile(`${__dirname}/data/${id}.json`,(err,data)=>{
    res.send(`${ab}(${data})`)
})
})
router.post('/msg', (req, res) => {
    let data = req.body.newMsg
    fs.writeFile(__dirname + '/data/1.json', data, () => {
        res.send('success');
    })


})
app.listen(8088)
